package com.demo.reduction;

import com.demo.common.Dish;
import com.demo.common.DishUtil;

import java.util.Comparator;
import java.util.List;
import java.util.Optional;

import static java.util.stream.Collectors.*;

public class TestMinMax {
    public static void main(String[] args) {
        List<Dish> menu = DishUtil.getDishes();
        Optional<Dish> mostCalorieDish = menu.stream()
                                             .collect(maxBy(Comparator.comparing(Dish::getCalories)));
        mostCalorieDish.ifPresent(t -> System.out.println(t.getName()));
    }
}
